import pygame
from pygame.locals import *
from sys import exit
from Alpha import *
import string
from Stages import *

screen = pygame.display.set_mode((630,510),0, 32)
elementos_fase = fase(1)

class Icone(pygame.sprite.Sprite):
    def __init__(self, estado ='jogador_unico'):
        self.image  = pygame.image.load('imagens/imagens_menu/selecao_jogadorunico.png')
        self.rect = self.image.get_rect()
        self.rect.top = 1
        self.rect.left = 335
        self.estado = estado
        self.nome_jogador = ''
    
    def loop(self,estado):
        if estado == 'instrucoes':
            for event in pygame.event.get():
                if event.type == QUIT:
                    exit()
                elif event.type == KEYDOWN:
                    if event.key == K_UP:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_jogadorunico.png')
                        self.rect.left = 335
                        self.estado = 'jogador_unico'
                    elif event.key == K_DOWN:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_recordes.png')
                        self.rect.left = 440
                        self.estado = 'recordes'
                    elif event.key == K_LEFT or event.key == K_RIGHT :
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_sair.png')
                        self.rect.top = 310 
                        self.estado = 'sair'
                    elif event.key == K_RETURN:
                        self.image  = pygame.image.load('imagens/imagens_menu/menu_instrucoes_1.png')
                        self.rect.top = 0
                        self.rect.left = 0
                        self.estado = 'tela_instrucoes_1'

        elif estado == 'recordes':
            for event in pygame.event.get():
                if event.type == QUIT:
                    exit()
                elif event.type == KEYDOWN:
                    if event.key == K_UP:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_instrucoes.png')
                        self.rect.left = 390
                        self.estado = 'instrucoes'
                    elif event.key == K_DOWN:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_jogadorunico.png')
                        self.rect.left = 335
                        self.estado = 'jogador_unico'
                    elif event.key == K_RETURN:
                        self.image  = pygame.image.load('imagens/imagens_menu/menu_recordes.png')
                        self.rect.top = 0
                        self.rect.left = 0
                        self.estado = 'tela_recordes'

        elif estado == 'creditos':
            for event in pygame.event.get():
                if event.type == QUIT:
                    exit()
                elif event.type == KEYDOWN:
                    if event.key == K_UP:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_sair.png')
                        self.rect.left = 390
                        self.estado = 'sair'
                    elif event.key == K_DOWN:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_sair.png')
                        self.rect.left = 390
                        self.estado = 'sair'
                    elif event.key == K_LEFT or event.key == K_RIGHT :
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_jogadorunico.png')
                        self.rect.top = 1 
                        self.estado = 'jogador_unico'
                    elif event.key == K_RETURN:
                        self.image  = pygame.image.load('imagens/imagens_menu/menu_creditos.png')
                        self.rect.top = 0
                        self.rect.left = 0
                        self.estado = 'tela_creditos'
                    
        elif estado == 'sair':
            for event in pygame.event.get():
                if event.type == QUIT:
                    exit()
                elif event.type == KEYDOWN:
                    if event.key == K_UP:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_creditos.png')
                        self.rect.left = 335
                        self.estado = 'creditos'
                    elif event.key == K_DOWN:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_creditos.png')
                        self.rect.left = 335
                        self.estado = 'creditos'
                    elif event.key == K_LEFT or event.key == K_RIGHT :
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_instrucoes.png')
                        self.rect.top = 1 
                        self.estado = 'instrucoes'
                    elif event.key == K_RETURN:
                        exit()

        elif estado =='tela_instrucoes_1':
            for event in pygame.event.get():
                if event.type == QUIT:
                    exit()
                elif event.type == KEYDOWN:
                    if event.key == K_BACKSPACE:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_jogadorunico.png')
                        self.rect.left = 335
                        self.rect.top = 1
                        self.estado = 'jogador_unico'
                    elif event.key == K_RIGHT:
                        self.image  = pygame.image.load('imagens/imagens_menu/menu_instrucoes_2.png')
                        self.estado = 'tela_instrucoes_2'
                
        elif estado =='tela_instrucoes_2':
            for event in pygame.event.get():
                if event.type == QUIT:
                    exit()
                elif event.type == KEYDOWN:
                    if event.key == K_BACKSPACE:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_jogadorunico.png')
                        self.rect.left = 335
                        self.rect.top = 1
                        self.estado = 'jogador_unico'
                    elif event.key == K_LEFT:
                        self.image  = pygame.image.load('imagens/imagens_menu/menu_instrucoes_1.png')
                        self.estado = 'tela_instrucoes_1'
                    elif event.key == K_RIGHT:
                        self.image  = pygame.image.load('imagens/imagens_menu/menu_instrucoes_3.png')
                        self.estado = 'tela_instrucoes_3'
                
        elif estado =='tela_instrucoes_3':
            for event in pygame.event.get():
                if event.type == QUIT:
                    exit()
                elif event.type == KEYDOWN:
                    if event.key == K_BACKSPACE:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_jogadorunico.png')
                        self.rect.left = 335
                        self.rect.top = 1
                        self.estado = 'jogador_unico'
                    elif event.key == K_LEFT:
                        self.image  = pygame.image.load('imagens/imagens_menu/menu_instrucoes_2.png')
                        self.estado = 'tela_instrucoes_2'

                    
        elif estado =='tela_creditos':
            for event in pygame.event.get():
                if event.type == QUIT:
                    exit()
                elif event.type == KEYDOWN:
                    if event.key == K_BACKSPACE:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_jogadorunico.png')
                        self.rect.left = 335
                        self.rect.top = 1
                        self.estado = 'jogador_unico'

        elif estado =='tela_recordes':
            for event in pygame.event.get():
                if event.type == QUIT:
                    exit()
                elif event.type == KEYDOWN:
                    if event.key == K_BACKSPACE:
                        self.image  = pygame.image.load('imagens/imagens_menu/selecao_jogadorunico.png')
                        self.rect.left = 335
                        self.rect.top = 1
                        self.estado = 'jogador_unico'
                
        
